package ar.com.angrymachine.uitest;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;

import ar.com.angrymachine.gameui.ButtonWidget;
import ar.com.angrymachine.gameui.Utils;
import ar.com.angrymachine.gameui.Widget;
import ar.com.angrymachine.gameui.ButtonWidget.ButtonListener;

public class UIDialog extends Widget implements ButtonListener
{
	private ButtonWidget close;

	public UIDialog(Widget parent, Rectangle area)
	{
		super(parent, area);
		close = new ButtonWidget(this, new Rectangle(100,100,100,30),"Close",this);
	}

	public void paint(Graphics g)
	{
		g.setColor(Color.GRAY);
		g.fillRect(0,0, getClientRect().width, getClientRect().height);
		Utils.drawString(g, "This is a dialog", 0, 0);
	}

	public void onPress(ButtonWidget widget)
	{
		if(widget == close)
		{
			close();
		}
	}
}
